using System;
using MetaObjects.Contracts;
using Microsoft.SharePoint;

namespace MetaObjects.SharePoint
{
	public class FieldText : FieldBase<SPFieldText, string>
	{
		public int MaxLength { get; set; }

		public FieldText() {}

		public FieldText(SPFieldText field)
			: base(field)
		{
			MaxLength = field.MaxLength;
		}

		public override Action<SPListItem, string> SetField
		{
			get { return (item, value) => item[InternalName] = value; }
		}

		public override Func<SPListItem, string> GetField
		{
			get { return item => (string)item[InternalName]; }
		}

		public override Func<SPFieldText, IMetaField> FieldFactory
		{
			get { return f => new FieldText(f); }
		}
	}
}